package com.yl.controller;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yl.model.Address;
import com.yl.model.Cart;
import com.yl.model.Category;
import com.yl.service.ICartService;
import com.yl.service.ICategoryService;
@ResponseBody
@Controller
public class CartController {

	
	@Resource
	private ICartService cartService;
	//显示购物车所有商品
	@RequestMapping("/findAllcart.do")
	public Map findAll(int user_id) {
		return cartService.findAll(user_id);
	}
	//删除购物车中的商品
	@RequestMapping("/delcart.do")
	public int del(int cart_id) {
		return cartService.del(cart_id);
	}
	//清空购物车
	@RequestMapping("/delAllcart.do")
	public int delAll(int user_id) {
		return cartService.delAll(user_id);
	}
   //修改商品数量
	@RequestMapping("/editcart.do")
	public int edit(Cart cart) {
		return cartService.edit(cart);
	}
	//添加到购物车
	@RequestMapping("/addcart.do")
	@ResponseBody
	public int addCart(Cart cart) {
		return cartService.addCart(cart);
	}
			
	//查询用户购物车商品种数
	@RequestMapping("/getCount.do")
	@ResponseBody
	public int getCount(int user_id) {
		return cartService.getCount(user_id);
	}
}
